package com.qianyu.project.mapper.provider.gs;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.ObjectUtils;

import java.util.Map;

/**
 * @author gs
 * @date create in 2021/2/2 9:37
 */
public class TenderPurchaseDetailMapperProvider {

    public String selectPageList(IPage page, Map<String, String> params) {
        return new SQL() {
            {
                SELECT("tpd.*,tpp.plan_editor,tpp.date,pi.project_name,mi.material_name,mi.unit,mi.unit_model");
                FROM("tender_purchase_plan tpp,tender_purchase_detail tpd,project_info pi,material_info mi");
                WHERE("tpp.id=tpd.plan_id and tpp.pro_id=pi.id and mi.id=tpd.mate_id");
                if (!ObjectUtils.isEmpty(params.get("planId"))) {
                    WHERE("tpd.plan_id like '%${params.planId}%'");
                }
                if (!ObjectUtils.isEmpty(params.get("materialName"))) {
                    WHERE("mi.material_name like '%${params.materialName}%'");
                }
                if (!ObjectUtils.isEmpty(params.get("providerName"))) {
                    WHERE("tpd.provider_name like '%${params.providerName}%'");
                }
                if (!ObjectUtils.isEmpty(params.get("projectName"))) {
                    WHERE("pi.project_name like '%${params.projectName}%'");
                }
            }
        }.toString();
    }
}
